package com.bookcloud.java21.chapter11.集合静态工厂方法115;

import java.util.List;
import java.util.Map;
import java.util.Set;

/** 集合静态工厂方法115 */
public class CollectionFactoryMethods {
  public static void main(String[] args) {
    // 1. 列表工厂方法
    List<String> list = List.of("A", "B", "C", "D", "E");
    System.out.println("列表元素：" + list);
    String[] array = {"A", "B", "C"};
    List<String> list2 = List.of(array);
    System.out.println("列表元素：" + list2);
    // 2. 集合工厂方法
    Set<String> set = Set.of("A", "B", "C");
    System.out.println("集合元素：" + set);
    // 3. 映射工厂方法
    Map<String, Integer> map = Map.of("A", 1, "B", 2, "C", 3);
    System.out.println("映射元素：" + map);
    System.out.println("A的映射值：" + map.get("A"));
    // 4. 空列表、集合、映射
    List<String> emptyList = List.of();
    Set<String> emptySet = Set.of();
    Map<String, Integer> emptyMap = Map.of();
    System.out.println("空列表：" + emptyList);
    System.out.println("空集合：" + emptySet);
    System.out.println("空映射：" + emptyMap);
  }
}
